
rm(list = ls())


## note: substitute directory location of file on local drive
res_note <- read.csv("~/scholarship/res_note_AOT/secondary.csv")



library("ggplot2", lib.loc="~/R/win-library/3.2")
library("ggthemes", lib.loc="~/R/win-library/3.2")


mytheme<-(theme_bw() + 
            theme(plot.background = element_blank(),
                  panel.grid.major = element_blank(),
                  panel.grid.minor = element_blank() )+
            theme(panel.border= element_blank())+
            theme(axis.line.x = element_line(color="black", size = 0.5),
                  axis.line.y = element_line(color="black", size = 0.5))) +
  theme(axis.title.y = element_blank(), axis.title.x = element_blank(), axis.text.x=element_text(size=16), axis.text.y=element_text(size=16)) +
  theme(legend.position="none")





jb=subset(res_note, res_note$AOT>-5 & res_note$conservrepub>-5 & WHYWARMER_c<2)

jb2=subset(res_note, res_note$AOT>-5 & res_note$conservrepub>-5 & WHYWARMER_c<2 & ld<2)

jb$AGW_f <- factor(jb$WHYWARMER_c)
levels=c(1:2)
labels=c("i dunno", "beats me")

jb2$ld_f <- factor(jb2$ld)
levels=c(1:2)
labels=c("i dunno", "beats me")

xss1<-jb$conservrepub
yss1=jb$AOT
xss2=jb$AOT
yss2=jb$WHYWARMER_c

p1= ggplot(jb, aes(x = conservrepub, y = AOT)) 
p2=ggplot(jb, aes(x=AOT,y=WHYWARMER_c))
p3=ggplot(jb2, aes(x=AOT,y=WHYWARMER_c, color=ld_f))


### Figure 2


p1 + geom_jitter(size=4, alpha=0.4, height=0.15, width=0.15, color="cyan") +geom_smooth(method="gam", formula = y ~ s(x, k=5), color="black", size=1.5, se=FALSE)  + mytheme +
  coord_cartesian(xlim=c(-1.8,1.8)) +    scale_x_continuous(breaks=c(-1.8,-1,0, 1,1.8))

p2 + geom_jitter(size=4, alpha=0.1, height=.25, width=0.25, color="cyan") +geom_smooth(method="gam", formula = y ~ s(x, k=5), color="black", size=1.5, se=FALSE)  + mytheme +
  coord_cartesian(ylim=c(0,1),xlim = c(-4,2.5))


#### left panel Figure 3



p3 + geom_jitter(size=4, alpha=0.14, height=.25, width=0.25) +geom_smooth(method="gam", formula = y ~ s(x, k=5), size=1.5, se=FALSE)  + mytheme +
  coord_cartesian(ylim=c(0,1),xlim = c(-4,3))+scale_color_manual(values=c("red","blue"))  +  
  scale_x_continuous(breaks=seq(-4, 2, 1))








